<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>#(webinfo.site_name)-用户注册</title>
    <meta name="description" content="#(webinfo.description)">
    <meta name="keywords" content="#(webinfo.keywords)">
    #include("../../common/css.html")
    <style>
    	.form-group.has-success .form-control-feedback:before, .input-group.has-success .form-control-feedback:before {
		    color: #4285f4 !important;
		    color: inherit;
		}
    </style>
</head>
<body>
    <div class="entry">
        <div class="entry-content">
            <div class="login-wrap">
                <div class="login-box forget-pwd-box padding-top-20">
                    <h5>注册【#(webinfo.site_name)】账号</h5>
                    <form class="margin-top-20" method="post"
                        name="RegForm" novalidate="" id="regForm">
                        <div class="form-group has-feddback">
                            <span class="input-icon">
                                <input type="text" class="form-control input-lg"
                                    placeholder="请输入企业名称" id="username" name="username">
                                <i class="aui-iconfont aui-icon-my darkgray"></i>
                            </span>
                        </div>
                        <div class="form-group">
                            <span class="input-icon">
                                <input type="password" onfocus="this.type='password'" class="form-control input-lg"
                                    placeholder="请设置您的登录密码" id="password" name="password">
                                <i class="aui-iconfont aui-icon-lock darkgray"></i>
                                <a class="pass-visible darkgray" href="#">
                                    <i class="fa fa-eye-slash"></i>
                                </a>
                            </span>
                        </div>
                        <div class="form-group">
                            <span class="input-icon">
                                <input type="password" onfocus="this.type='password'" name="confirm" id="confirm" class="form-control input-lg"
                                    placeholder="请确认您的登录密码" >
                                <i class="aui-iconfont aui-icon-lock darkgray"></i>
                                <a class="pass-visible darkgray" href="#">
                                    <i class="fa fa-eye-slash"></i>
                                </a>
                            </span>
                        </div>
                        <div class="form-group margin-top-30">
                            <div class="checkbox">
                                <label>
                                    <input class="check" type="checkbox" id="agree" name="agree">
                                    <span class="text">我已阅读并同意
                                        <a href="#" class="btn-link" data-toggle="modal" data-target="#ruleModal">《#(webinfo.site_name)服务协议》</a>
                                    </span>
                                </label>
                            </div>
                        </div>
                        <button class="btn btn-block btn-primary btn-lg pwd-submit" type="submit" id="btn_submit">注 册</button>
                        <div class="login-ft margin-top-30">
                            <a href="#(ctx)" class="btn-link pull-left">&lt; 返回首页</a>
                            <span class="pull-right">已有#(webinfo.site_name)帐号？
                                <a href="#(ctx)/auth/login" class="btn-link">我要登录</a>
                            </span>
                        </div>
                    </form>
                </div>
                <!-- 协议Modal -->
                <div class="modal fade bs-example-modal-lg" id="ruleModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="display: none;">
                    <div class="modal-dialog modal-lg" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal">
                                    <span aria-hidden="true">×</span>
                                    <span class="sr-only">Close</span>
                                </button>
                                <h4 class="modal-title">#(webinfo.site_name)服务协议</h4>
                            </div>
                            <iframe src="#(ctx)/auth/xieyi" style="width: 100%;min-height: 600px;border:0;"></iframe>
                        </div>
                    </div>
                </div>
            </div>
            <div class="entry-footer text-center">
                <p class="no-margin-bottom">#(webinfo.copy)| #(webinfo.icp) | 通讯地址：#(webinfo.addr)</p>
                <!-- <h3>400-000-0000</h3> -->
                <p>#(webinfo.worktime)</p>
            </div>
        </div>
    </div>
    #include("../../common/js.html")
    <script src="https://cdn.bootcss.com/jquery-validate/1.17.0/jquery.validate.js"></script>
	<script src="https://cdn.bootcss.com/jquery-validate/1.17.0/localization/messages_zh.min.js"></script>
    <script>
    	$(function(){
    		$("#regForm").validate({
                errorElement: 'span',
                errorClass: 'help-block',
                rules: {
                	username: {
                        required: true
                    },
                    password: {
                        required: true,
                        minlength: 6
                    },
                    confirm: {
                        required: true,
                        minlength: 6,
                        equalTo: "#password"
                    },
                    
                },
                messages: {
                    username: {
                        required: '请输入企业名称'
                    },
                    password: {
                        required: "请输入密码!",
                        minlength: jQuery.validator.format("密码不能小于{0}个字 符")
                    },
                    confirm: {
                        required: "请输入确认密码",
                        minlength: "确认密码不能小于6个字符",
                        equalTo: "两次输入密码不一致"
                    },
                    
                },
                errorPlacement: function (error, element) {
                    element.next().remove();
                    element.after(
                        '<span class="glyphicon glyphicon-remove form-control-feedback" aria-hidden="true" style="font-size:12px;"></span>'
                    );
                    element.closest('.form-group').append(error);
                },
                highlight: function (element) {
                    $(element).closest('.form-group').addClass('has-error has-feedback');
                },
                success: function (label) {
                    var el = label.closest('.form-group').find("input");
                    //console.log(el);
                    el.next().remove();
                    el.after(
                        '<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true" style="font-size:12px;"></span>'
                    );
                    label.closest('.form-group').removeClass('has-error').addClass(
                        "has-feedback has-success");
                    label.remove();
                    
                },
                submitHandler:function(form){
                	console.log("submitHandler")
                	var checked=$("#agree").is(':checked');
                	if(!checked){
                		layer.msg('请勾选服务协议');
                	}else{
                		var _username=$("#username").val();
                		var _password=$("#password").val();
                		var data={username:_username,password:_password};
                		$("#btn_submit").text("注册中...,请不要离开");
                		$("#btn_submit").attr("disabled",true);
                		$.post("#(ctx)/auth/ajaxReg",data,function(data){
                			layer.msg(data.msg);
                			if(data.code==0){
                				setTimeout(function(){
                					window.location.href="#(ctx)";
                				},2000);
                			}else{
                				$("#btn_submit").text("注册");
                        		$("#btn_submit").attr("disabled",false);
                			}
                		},'json');

                	}
                }
            });
    	});
	  	//密码是否可见
		$(".pass-visible>i").on('click',function(){
			if($(this).hasClass('fa-eye')){
				$(this).removeClass('fa-eye').addClass('fa-eye-slash');
				$(this).parents('.input-icon').find('input').attr("type","password");
			}else{
				$(this).removeClass('fa-eye-slash').addClass('fa-eye');
				$(this).parents('.input-icon').find('input').attr("type","text");
			}
		})
    </script>
</body>

</html>